﻿<?php
@session_start();

require_once("../../class/mysql.class.php");
  $obj = new Mysql();
  $obj -> set_table('user_login');
  $obj -> set_colone("(`*`)");
  $obj -> set_variables(" id_login = '" . $_SESSION["id"] . "' ");
  $user = $obj -> select_enregistrement();
 // echo $user['id_login'];
  
if (isset($_REQUEST['unit_stockage']))
{
	$unit = addslashes($_REQUEST["unit_stockage"]); 
	$nbrs=	addslashes($_REQUEST["nb_pieces"]);
	$desc= addslashes($_REQUEST["desc_unit"]);
	$req="SELECT * FROM `st_att_unite_stockage` WHERE valeur='".$unit."'";
	$num = mysql_num_rows(mysql_query($req));
	if($num<1){
		$sql = "INSERT INTO `st_att_unite_stockage` (`id_unite_stockage`, `valeur`, `nb_pieces`,`description`) 
		VALUES 
		('', '".$unit."','".$nbrs."','".$desc."');";
		mysql_query($sql);
		header('location:../../list_stock_type.php?action=added&unit='.$unit);
	}else{
		header('location:../../list_stock_type.php?action=addedError&unit='.$unit);
	}
}
